package com.changgou.framework.exception;

import com.changgou.util.Result;
import com.changgou.util.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/*****
 * @Author: 黑马训练营
 * @Description: com.changgou.framework.exception
 ****/
//@ControllerAdvice   //所有请求路径，都将被该类处理->过滤器/(拦截器)
public class BaseExceptionHandler {

    /***
     * 异常处理
     * 当前请求发生了指定异常，则执行该方法处理异常
     */
    //@ExceptionHandler(Exception.class)
    //@ResponseBody
    public Result error(Exception ex){
        ex.printStackTrace();
        return new Result(true, StatusCode.ERROR,ex.getMessage());
    }
}
